//一级商品列表
var stairgoods = $('#stairgoodsC').html();
var menuPage = Handlebars.compile(stairgoods);

var vfpgoods = $('#vfpgoodsC').html();
var menuPages = Handlebars.compile(vfpgoods);
$.ajax({
	type:"get",
	url:URL.interface.getCategoryList,
	dataType:"json",  
	data:{
		level:1
	},
	success:function(e){
//		console.log(e)
		if(e.code == '10000'){
			$("#stairgoods").html(menuPages(e.data));
			
			$('#stairgoods div').click(function(){
				var id = $(this).attr("id");
				localStorage.setItem('stairid',$(this).attr("codeid"));
				localStorage.setItem('vfpid','');
				var index = $(this).index();
				$(this).addClass('on').siblings().removeClass('on');
				$('.stairname').html($(this).html());
				$('.vfpname').html('');
				//二级商品列表
				$.ajax({
					type:'post',
					url:URL.interface.getCategoryList,
					data:{
						pcode:id
					},
					success:function(e){
						if(e.code == '10000'){
							if(e.data.length == 0){
								$("#vfpgoods").html(menuPages(e.data));
								$('#vfpgoods div').click(function(){
									localStorage.setItem('vfpid',$(this).attr("codeid"))
									var index = $(this).index();
									$(this).addClass('on').siblings().removeClass('on');
									$('.vfpname').html($(this).html())
								})
								alert('暂无数据')
							}else{
								$("#vfpgoods").html(menuPages(e.data));
								$('#vfpgoods div').click(function(){
									localStorage.setItem('vfpid',$(this).attr("codeid"))
									var index = $(this).index();
									$(this).addClass('on').siblings().removeClass('on');
									$('.vfpname').html($(this).html())
								})
							}
								
						}
					}
				})
				
			})
			
		}
	}
}); 

//下一步
$('.nextStep').click(function(){
	var stairname = $('.stairname').html();
	var vfpname = $('.vfpname').html();
	
	if(stairname !='' && vfpname!=''){
		window.location.href = './thesecondstep.html';
		localStorage.setItem('stairname',stairname);
		localStorage.setItem('vfpname',vfpname);
	}else{
		
	}
	
})

$('.navigation_n div').hover(function(){
	var index = $(this).index();
	if(index == 1){
		$('.navigation_n div ul li').click(function(e){
			e.stopPropagation();
			var index = $(this).index();
			if(index == 0){
				window.location.href = './firststep.html'
			}else if(index == 1){
				window.location.href = './specification.html'
			}else if(index == 2){
				window.location.href = './trademark.html'
			}
		})
	}else if(index == 2){
		$('.navigation_n div ul li').click(function(e){
			e.stopPropagation();
			var index = $(this).index();
			if(index == 0){
				window.location.href = '../indent/goodsindent.html'
			}else if(index == 2){
				window.location.href = '../indent/evaluate.html'
			}
		})
	}
})